package com.like.miaosha.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
@Service
public class RedisPoolFactory {
    @Autowired
    RedisConfig redisconfig;
    @Bean
    public JedisPool JedisPoolFactory(){
        JedisPoolConfig jedisPoolConfig =new JedisPoolConfig();
        jedisPoolConfig.setMaxIdle(redisconfig.getPoolMaxIdle());
        jedisPoolConfig.setMaxTotal(redisconfig.getPoolMaxTotal());
        jedisPoolConfig.setMaxTotal(redisconfig.getPoolMaxWait()*1000);
        JedisPool jp= new JedisPool(jedisPoolConfig,redisconfig.getHost(),redisconfig.getPort(),redisconfig.getTimeout()*1000,redisconfig.getPassword(),0);
        return jp;
    }
}
